/* 变量定义 */
$primary-color: #4e6ef2;
$hover-color: #4058c9;
$text-color: #333;
$text-secondary: #666;
$border-color: #ddd;
$bg-color: #f5f5f5;
$card-bg: #f5f5f5;
$white: #fff;
$header-height: 60px;
$sidebar-width: 240px;
$border-radius: 4px;

// Mixins
@mixin flex-center {
  display: flex;
  align-items: center;
}

@mixin card-hover {
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 0, 0, 0);

  &:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #4058c9;
  }
}

@mixin text-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

// 样式
.home-container {
  min-height: 100vh;
  background: $bg-color;
  font-family: '楷体', sans-serif;
  font-size: 16px;
}

.main {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: $sidebar-width;
  background: $white;
  padding: 0;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  border-right: 1px solid $border-color;
  display: flex;
  flex-direction: column;
  align-items: center;

  .logo {
    font-size: 28px;
    font-weight: bold;
    height: 60px;
    cursor: pointer;
    @include flex-center;

    i {
      font-size: 28px;
      margin-right: 10px;
      color: $primary-color;
    }
  }

  .menu {
    width: 100%;
  }

  .menu-item {
    padding: 15px 0;
    cursor: pointer;
    width: 100%;
    transition: all 0.3s ease;
    position: relative;

    .menu-content {
      width: 160px;
      margin: 0 auto;
      @include flex-center;

      i {
        font-size: 18px;
        width: 24px;
        height: 24px;
        @include flex-center;
        justify-content: center;
        margin-right: 12px;
      }

      span {
        width: 80px;
        @include text-ellipsis;
      }
    }

    &:hover {
      background: $bg-color;
      color: $primary-color;

      &::after {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 4px;
        background: $primary-color;
      }
    }

    &.active {
      background: $bg-color;
      color: $primary-color;

      &::after {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 4px;
        background: $primary-color;
      }
    }
  }
}

.right-content {
  flex: 1;
  margin-left: $sidebar-width;
}

.header {
  height: $header-height;
  background: $white;
  @include flex-center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid $border-color;
  position: sticky;
  top: 0;
  z-index: 100;

  .search {
    flex: 1;
    display: flex;
    max-width: 600px;

    input {
      flex: 1;
      height: 36px;
      padding: 0 15px;
      border: 1px solid $border-color;
      border-radius: $border-radius 0 0 $border-radius;
      outline: none;

      &:focus {
        border-color: $primary-color;
      }
    }

    button {
      width: 100px;
      height: 36px;
      background: $primary-color;
      color: $white;
      border: none;
      border-radius: 0 $border-radius $border-radius 0;
      cursor: pointer;
      transition: background-color 0.3s;

      &:hover {
        background: $hover-color;
      }
    }
  }

  .header-right {
    margin-left: 20px;
    display: flex;
    gap: 16px;

    span {
      cursor: pointer;

      &:hover {
        color: $primary-color;
      }
    }
  }
}

.content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section {
  background: $white;
  border-radius: $border-radius;
  padding: 20px;

  &-header {
    font-weight: 600;
    font-size: 18px;
    margin-bottom: 16px;
    @include flex-center;

    i {
      margin-right: 8px;
    }
  }
}

.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}

.card {
  background: $card-bg;
  border-radius: $border-radius;
  padding: 15px;
  @include flex-center;
  cursor: pointer;
  @include card-hover;

  &-icon {
    width: 40px;
    height: 40px;
    background: #eee;
    border-radius: $border-radius;
    margin-right: 12px;
    @include flex-center;
    justify-content: center;
  }

  &-content {
    flex: 1;
    min-width: 0;
  }

  &-title {
    font-weight: bold;
    margin-bottom: 4px;
    @include text-ellipsis;
  }

  &-desc {
    font-size: 12px;
    color: $text-secondary;
    max-height: 32px; // 设置最大高度为两行文本的高度（12px * 1.4 * 2 ≈ 32px）
    line-height: 1.4;
    overflow: hidden;
  }
}

// 响应式设计
@media screen and (max-width: 768px) {
  .sidebar {
    width: 0;
    transform: translateX(-100%);
  }

  .right-content {
    margin-left: 0;
  }

  .card-list {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (max-width: 768px) { /* 根据需要调整最大宽度 */
  .sidebar {
    display: none; /* 在手机端隐藏侧边栏 */
  }
}

.icon-size {
  width: 32px;
  /* 设置统一的宽度 */
  height: 32px;
  /* 设置统一的高度 */
}

.item {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: all 0.3s;
  /* 保持原有的样式 */
  display: flex;
  align-items: center;
  padding: 15px;
  border-radius: 8px;
  margin: 10px;
  border: 1px solid rgba(255, 0, 0, 0);
}

.item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid #4058c9;
}

.icon {
  width: 32px;
  height: 32px;
  margin-right: 12px;
  object-fit: contain;
}

.item-info {
  flex: 1;
}

.item-info h3 {
  margin: 0;
  font-size: 16px;
  color: #333;
}

.item-info p {
  margin: 5px 0 0;
  font-size: 14px;
  color: #666;
}

/* 加载动画样式 */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  margin-top: 20px;
  font-size: 16px;
  color: #333;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}